package com.feature.shop.user.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.feature.core.domain.PageVo;
import com.feature.core.mybatis.BaseService;
import com.feature.core.mybatis.SmartBaseMapper;
import com.feature.shop.user.api.request.ShopRoleAuthListRequest;
import com.feature.shop.user.api.request.ShopRoleAuthPageRequest;
import com.feature.shop.user.api.vo.ShopRoleAuthVo;
import com.feature.shop.user.mapper.ShopRoleAuthMapper;
import com.feature.shop.user.converter.ShopRoleAuthConverter;
import com.feature.shop.user.model.entity.ShopRoleAuthEntity;

/***
 * 用户角色权限表Service
 */
@Service
public class ShopRoleAuthService extends BaseService<ShopRoleAuthEntity> {
    @Autowired
    private ShopRoleAuthMapper shopRoleAuthMapper;

    @Autowired
    private ShopRoleAuthConverter shopRoleAuthConverter;

    @Override
    public SmartBaseMapper<ShopRoleAuthEntity> getSmartBaseMapper() {
        return shopRoleAuthMapper;
    }

    public PageVo<ShopRoleAuthVo> findPageList(ShopRoleAuthPageRequest req) {
        PageVo<ShopRoleAuthEntity> pageData = shopRoleAuthMapper.selectPageList(req.getCurPage(), req.getPageSize(), shopRoleAuthConverter.pageRequestToQuery(req));
        PageVo<ShopRoleAuthVo> vo = PageVo.of(pageData, shopRoleAuthConverter::entityListToVO);
        return vo;

    }

    public List<ShopRoleAuthVo> findList(ShopRoleAuthListRequest req) {
        List<ShopRoleAuthEntity> list = shopRoleAuthMapper.selectList(shopRoleAuthConverter.listRequestToQuery(req));
        return shopRoleAuthConverter.entityListToVO(list);
    }

    @Override
    public Class<ShopRoleAuthEntity> getEntityClass() {
        return ShopRoleAuthEntity.class;
    }

}
